package com.migu.rbac.util;

import com.migu.rbac.model.SysUser;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;

public class UserUtils {

    /*
            User currentHr = UserUtils.getCurrentHr();
            username=用户id
            currentHr.getUsername();
     */
    public static User getCurrentHr() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if ("anonymousUser".equals(principal)) {
            return null;
        } else {
            return (User) principal;
        }

    }
}
